package com.icss.clothes.mapper;
import com.icss.clothes.entity.Buy;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 有关商品收藏的Mapper
 */
@Mapper
public interface WishlistMapping {
    //添加收藏
    @Insert("insert into collection(user_id,c_id) values(#{user_id},#{c_id})")
    public void addCollection(Buy buy);

    //查询收藏是否已经存在收藏
    @Select("select * from collection where user_id=#{user_id} and c_id=#{c_id}")
    public Buy findSameCollection(Buy buy);

    //删除收藏
    @Delete("delete from collection where c_id=#{c_id} and user_id=#{user_id}")
    public void deleteCollection(int c_id,int user_id );

    //查看收藏
    @Select("select c_name,c_picture1,c_price,c.c_id from commodity c" +
            " left outer join collection col on c.c_id=col.c_id " +
            "left outer join commodity_detail cd on c.c_id=cd.c_id " +
            "where user_id=#{user_id} and cd_bha=1 ")
    public List<Buy> lookCollection(int user_id);


}
